package cn.rkylin.oms.sysrefund.dao.impl;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.sysrefund.dao.ISysRefundDAO;
import cn.rkylin.oms.sysrefund.domain.SysRefund;
import cn.rkylin.oms.sysrefund.vo.SysRefundVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * 类名:SysRefundDAOImpl <br/>
 * 作用: 系统退款单数据访问层实现类. <br/>
 * 创建原因:	 系统退款单数据访问层实现类. <br/>
 * 创建时间:     2017年9月22日 上午11:33:24 <br/>
 *
 * @author zhanghao
 * @version v1.0
 */
@Repository
public class SysRefundDAOImpl implements ISysRefundDAO {
    @Autowired
    IDataBaseFactory dao;

    private String STATEMENT_INSERT_BATCH_SYSREFUND = "insertBatchSysRefund";
    private String STATEMENT_INSERT_SELECTIVE_SYSREFUND = "insertSelectiveSysRefund";
    private String STATEMENT_SELECT_SYSREFUND_4_UPDATE = "selectSelectiveSysRefund4Update";
    private String STATEMENT_UPDATE_SELECTIVE_SYSREFUND = "updateByPrimaryKeySelectiveSysRefund";
    private String STATEMENT_SELECT_SYSREFUND_BYCONDITION = "selectSysRefundByCondition";

    public SysRefundDAOImpl() {

    }

    /**
     * @see cn.rkylin.oms.sysrefund.dao.ISysRefundDAO#deleteByPrimaryKey(java.lang.String)
     */
    @Override
    public int deleteByPrimaryKey(String refundId) {

        
        return 0;
    }

    /**
     * 批量插入记录.
     *
     * @throws Exception
     * @see cn.rkylin.oms.sysrefund.dao.ISysRefundDAO#insert(cn.rkylin.oms.sysrefund.vo.SysRefundVO)
     */
    @Override
    public int insertBatch(List<SysRefundVO> recordList) throws Exception {
        return dao.insertBatch(STATEMENT_INSERT_BATCH_SYSREFUND, recordList);
    }

    /**
     * 选择插入.
     *
     * @throws Exception
     * @see cn.rkylin.oms.sysrefund.dao.ISysRefundDAO#insertSelective(cn.rkylin.oms.sysrefund.domain.SysRefund)
     */
    @Override
    public int insertSelective(SysRefund record) throws Exception {
        return dao.insert(STATEMENT_INSERT_SELECTIVE_SYSREFUND, record);
    }

    /**
     *
     * @param refundId
     * @return
     * @throws Exception
     */
    @Override
    public SysRefund selectByPrimaryKey(String refundId) throws Exception {
        List<SysRefund> sysRefundList = dao.findList("selectSysRefundById", refundId);
        if (sysRefundList != null && sysRefundList.size()>0){
            return sysRefundList.get(0);
        }else {
            return null;
        }
    }

    /**
     *通过订单id获取退款单信息
     * @param orderId
     * @return
     * @throws Exception
     */
    @Override
    public List<SysRefund> selectSysRefundByOrderID(String orderId) throws Exception {
        List<SysRefund> sysRefundList = dao.findList("selectSysRefundByOrderID", orderId);
        return sysRefundList;
    }


    /**
     * 更新系统退款单.
     * @throws Exception 
     *
     * @see cn.rkylin.oms.sysrefund.dao.ISysRefundDAO#updateByPrimaryKeySelective(cn.rkylin.oms.sysrefund.domain.SysRefund)
     */
    @Override
    public int updateByPrimaryKeySelective(SysRefundVO record) throws Exception {
        return dao.update(STATEMENT_UPDATE_SELECTIVE_SYSREFUND, record);
    }

    /**
     * 
     *
     * @see cn.rkylin.oms.sysrefund.dao.ISysRefundDAO#updateByPrimaryKey(cn.rkylin.oms.sysrefund.domain.SysRefund)
     */
    @Override
    public int updateByPrimaryKey(SysRefund record) {

        
        return 0;
    }

    /**
     * 
     *
     * @see cn.rkylin.oms.sysrefund.dao.ISysRefundDAO#insert(cn.rkylin.oms.sysrefund.domain.SysRefund)
     */
    @Override
    public int insert(SysRefund record) {


        return 0;
    }

    /**
     * 
     *
     * @see cn.rkylin.oms.sysrefund.dao.ISysRefundDAO#selectBySelectiveKey(cn.rkylin.oms.sysrefund.vo.SysRefundVO)
     */
    @Override
    public List<SysRefundVO> selectBySelectiveKey4Update(SysRefundVO sysRefundVO) throws Exception {
        List<SysRefundVO> returnList = new ArrayList<SysRefundVO>();
        returnList = dao.findAllList(STATEMENT_SELECT_SYSREFUND_4_UPDATE, sysRefundVO);
        return returnList;
    }
    /**
     * 按条件获取系统退款单列表
     *
     * @param sysRefundVO
     * @return
     * @throws Exception
     */
    public List<SysRefundVO> selectSysRefundListByCondition(SysRefundVO sysRefundVO) throws Exception {
        return dao.findAllList(STATEMENT_SELECT_SYSREFUND_BYCONDITION, sysRefundVO);
    }

}

